<?php

namespace app\api\controller\v37;

use app\api\controller\v2\Auth;
use app\common\cachemodel\AppConfig;
use app\common\cachemodel\Goods;
use app\common\cachemodel\MallGoods;
use app\common\cachemodel\Recode as RecodeModel;
use app\common\cachemodel\zl4\Zl4GoodTimeTag;
use app\common\cachemodel\zl4\Zl4GoodTimeType;
use app\common\cachemodel\zl4\Zl4HoroscopeGoodTime;
use app\common\cachemodel\zl4\Zl4HoroscopeGoodTimeIsNew;
use app\common\cachemodel\zl4\Zl4HoroscopeGoodTimeTemp;
use app\common\cachemodel\zl4\Zl4HoroscopeReport;
use app\common\cachemodel\zl4\Zl4HoroscopeUserConfig;
use app\common\lib\horoscope\Horoscope as HoroscopeReport;
use app\common\lib\horoscope\HoroscopeFortune;
use app\common\lib\Util;
use think\Env;
use think\response\Json;
use XznsTools\cache\CacheManage;

class Horoscope extends Auth
{
    /**
     * 八字首页
     * @return Json
     * @throws \Exception
     */
    public function home()
    {
        $rid = input('rid/d', 0);
        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }
        $horoscopeUserConfigModel = new Zl4HoroscopeUserConfig();
        // 获取用户 八字排盘 配置信息
        $userConfig = $horoscopeUserConfigModel->getUserConfig($this->user['id']);

        $timeType = $userConfig['config']['time_model1'] === 1 ? 0 : 1; // 1=>北京时间 2=>真太阳时
        $timeStart = $userConfig['config']['time_model2'] === 1 ? 23 : 0;   // 1=>23点 2=>24点
        [$y, $m, $d, $h, $i] = explode(',', date('Y,m,d,H,i'));
        $instance = HoroscopeReport::getInstance([
            'recode' => $recodeInfo,
            'time_start' => $timeStart,
            'time_type' => $timeType,
            'shensha' => $userConfig['config']['shensha'],
            'liuyue' => $userConfig['config']['liuyun'],
            'advance' => [
                'year' => (int)$y,
                'month' => (int)$m,
                'day' => (int)$d,
                'hour' => (int)$h,
                'minute' => (int)$i,
                'timezone' => 8,
                'is_summer' => 0,
            ],
        ]);
        $baziData = $instance->getUserData3();

        $tianganGuanxi = [];
        if (!empty($baziData['guanxi']) && isset($baziData['guanxi']['tiangan_guanxi']) && !empty($baziData['guanxi']['tiangan_guanxi']))
        {
            foreach ($baziData['guanxi']['tiangan_guanxi'] as $item)
            {
                $tianganGuanxi[] = [
                    'index_list' => $item['index_list'],
                    'color' => $item['color'],
                    'name' => $item['name'],
                ];
            }
        }
        $dizhiGuanxi = [];
        if (!empty($baziData['guanxi']) && isset($baziData['guanxi']['dizhi_guanxi']) && !empty($baziData['guanxi']['dizhi_guanxi']))
        {
            foreach ($baziData['guanxi']['dizhi_guanxi'] as $item)
            {
                $dizhiGuanxi[] = [
                    'index_list' => $item['index_list'],
                    'color' => $item['color'],
                    'name' => $item['name'],
                ];
            }
        }
        $baziData['guanxi']['tiangan_guanxi'] = $tianganGuanxi;
        $baziData['guanxi']['dizhi_guanxi'] = $dizhiGuanxi;

        $baziData['recode_info']['name'] = (int)$recodeInfo['isself'] === 1 ? '自己' : $recodeInfo['name'];

        $utilTool = new Util();
        if ($recodeInfo['timezone'])
        {
            if ($recodeInfo['timezone'] > 0)
            {
                $timezone = '东' . $utilTool->numberChinese($recodeInfo['timezone']) . '区 GMT+' . $recodeInfo['timezone'];
            } else
            {
                $timezone = '西' . $utilTool->numberChinese(abs($recodeInfo['timezone'])) . '区 GMT' . $recodeInfo['timezone'];
            }
        } else
        {
            $timezone = '中时区 GMT0';
        }
        $baziData['recode_info']['brithday1'] = $baziData['recode_info']['brithday1'] . "（{$timezone}）";

        $baziData['btn_list'] = (new Zl4HoroscopeReport())->getTabBtnList(['八字解读', '72格局判定', '用神详解', '评分起名', '吉日吉时'], $recodeInfo);

        $baziData['config_info'] = $userConfig['config'];

//        $baziData['is_need_show_tip'] = 1; // 真太阳时是否影响八字信息，客户端进行提示

        return show(config('code.success'), '请求成功', $baziData);
    }

    /**
     * 设置 八字排盘 配置信息
     * @return Json
     * @throws \Exception
     */
    public function setConfig()
    {
        $timeModel1 = input('time_model1/d', -999);
        $timeModel2 = input('time_model2/d', -999);
        $shensha = input('shensha/d', -999);
        $liuyun = input('liuyun/d', -999);
        $color = input('color/d', -999);

        $updateData = [];
        if (in_array($timeModel1, [1, 2], true))
        {
            $updateData['time_model1'] = $timeModel1;
        }
        if (in_array($timeModel2, [1, 2], true))
        {
            $updateData['time_model2'] = $timeModel2;
        }
        if (in_array($shensha, [0, 1, 2], true))
        {
            $updateData['shensha'] = $shensha;
        }
        if (in_array($liuyun, [0, 1], true))
        {
            $updateData['liuyun'] = $liuyun;
        }
        if ($color !== -999)
        {
            $updateData['color'] = $color;
        }

        if (empty($updateData))
        {
            return show(config('code.error'), '请求异常，请稍后再试～');
        }

        $horoscopeUserConfigModel = new Zl4HoroscopeUserConfig();
        // 获取用户 八字排盘 配置信息
        $userConfig = $horoscopeUserConfigModel->getUserConfig($this->user['id']);
        // 更新用户 八字排盘 配置信息
        $userConfig['config'] = array_merge($userConfig['config'], $updateData);
        $res = $horoscopeUserConfigModel->setUserConfig($this->user['id'], $userConfig);
        if ($res)
        {
            return show(config('code.success'), '设置成功');
        } else
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }
    }

    /**
     * 八字解读
     * @return Json
     * @throws \Exception
     */
    public function analysisInfo()
    {
        $rid = input('rid/d', 0);

        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }

        $bazijiedu = HoroscopeFortune::getInstance()->setAdvance(date('Y-m-d'))->setRecord($recodeInfo)->bazijiedu();

        $total = 0;
        $max = ['k' => -1, 'value' => 0];
        $min = ['k' => -1, 'value' => 100];
        foreach ($bazijiedu['wuxing']['list'] as $k => $item)
        {
            $bazijiedu['wuxing']['list'][$k]['score'] = (int)$item['score'];
            $total += $bazijiedu['wuxing']['list'][$k]['score'];

            if ($bazijiedu['wuxing']['list'][$k]['score'] > $max['value'])
            {
                $max = ['k' => $k, 'value' => $bazijiedu['wuxing']['list'][$k]['score']];
            }
            if ($bazijiedu['wuxing']['list'][$k]['score'] < $min['value'])
            {
                $min = ['k' => $k, 'value' => $bazijiedu['wuxing']['list'][$k]['score']];
            }
        }

        if ($total > 100)
        {
            $add = $total - 100;
            $bazijiedu['wuxing']['list'][$min['k']]['score'] += $add;
        } elseif ($total < 100)
        {
            $add = 100 - $total;
            $bazijiedu['wuxing']['list'][$max['k']]['score'] -= $add;
        }

        $btnList = (new Zl4HoroscopeReport())->getTabBtnList(['72格局判定', '用神详解', '评分起名', '吉日吉时'], $recodeInfo);

        return show(config('code.success'), '请求成功', [
            'wuxing' => $bazijiedu['wuxing'],
            'shishen' => $bazijiedu['shishen'],
            'btn_list' => $btnList,
        ]);
    }

    /**
     * 用神详解 详情
     * @return Json
     * @throws \Exception
     */
    public function yongshenInfo()
    {
        $rid = input('rid/d', 0);

        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }

        $HoroscopeReportModel = new Zl4HoroscopeReport();
        $HoroscopeReportInfo = $HoroscopeReportModel->getReport($recodeInfo, [2]);
        if (empty($HoroscopeReportInfo))
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }
        $HoroscopeReportInfo = current($HoroscopeReportInfo);

        switch ($HoroscopeReportInfo['status'])
        {
            case 0: // 待计算
                $status = 0;
                $intro = '为了做出更准确的判断，请根据自己的实际情况，在以下年份中选出：你认为整体感觉最好的年份和最不好的年份。我们将结合你的实际情况给出更准确的解读。';
                $years = [];
                $nowYear = date('Y');
                for ($i = 1; $i <= 20; $i++)
                {
                    $y = $nowYear - $i;
                    if ($y > $recodeInfo['year'])
                    {
                        $years[] = $y;
                    } else
                    {
                        break;
                    }
                }
                asort($years);
                $years = array_values($years);
                $goodYear = [
                    'title' => '最好的年份',
                    'des' => '最多可以选择三年',
                    'time_list' => $years,
                ];
                $badYear = [
                    'title' => '最不好的年份',
                    'des' => '最多可以选择三年',
                    'time_list' => $years,
                ];
                break;
            case 2: // 计算完成
                $status = 1;
                $intro = "用神就是你喜欢的五行，可以用来调整改善你的人生。\r\n由于八字解读手法众多，用神取法各有不同，我们综合各种常见手法得出以下结果，请根据需求酌情参考。";

                $colorConfig = [
                    'wuxing_attr_color' => [ // 五行属性颜色
                        '木' => [
                            'color' => '#24252A',
                            'bg_color' => '#5BBB87',
                            'bg_border_color' => '#5BBB87',
                        ],
                        '火' => [
                            'color' => '#24252A',
                            'bg_color' => '#EC8337',
                            'bg_border_color' => '#EC8337',
                        ],
                        '土' => [
                            'color' => '#24252A',
                            'bg_color' => '#C5C0C0',
                            'bg_border_color' => '#C5C0C0',
                        ],
                        '金' => [
                            'color' => '#24252A',
                            'bg_color' => '#FDC756',
                            'bg_border_color' => '#FDC756',
                        ],
                        '水' => [
                            'color' => '#24252A',
                            'bg_color' => '#5F7CEE',
                            'bg_border_color' => '#5F7CEE',
                        ],
                    ],
                    'color_color' => [ // 颜色 颜色
                        '木' => [    // 绿色
                            'color' => '#FFFFFF',
                            'bg_color' => '#35BD58',
                            'bg_border_color' => '#35BD58',
                        ],
                        '火' => [    // 红色
                            'color' => '#FFFFFF',
                            'bg_color' => '#D34242',
                            'bg_border_color' => '#D34242',
                        ],
                        '土' => [    // 黄色
                            'color' => '#FFFFFF',
                            'bg_color' => '#F2A428',
                            'bg_border_color' => '#F2A428',
                        ],
                        '金' => [    // 白色
                            'color' => '#24252A',
                            'bg_color' => '#FFFFFF',
                            'bg_border_color' => '#F1F1F1',
                        ],
                        '水' => [    // 蓝黑色
                            'color' => '#FFFFFF',
                            'bg_color' => '#3A457B',
                            'bg_border_color' => '#3A457B',
                        ],
                    ],
                ];
                $wuxingAttr = $HoroscopeReportInfo['content']['quming'];

                $wuxingQumingTextConfig = [
                    '木' => ['林', '松', '芳', '菲', '桃'],
                    '火' => ['炎', '旭', '晓', '晨', '智'],
                    '土' => ['于', '山', '坤', '峰', '仙'],
                    '金' => ['聪', '柔', '剑', '宁', '静'],
                    '水' => ['雨', '雪', '美', '米', '平'],
                ];

                $qumingTexts = [];
                foreach ($wuxingQumingTextConfig[$wuxingAttr] as $text)
                {
                    $qumingTexts[] = [
                        'name' => $text,
                        'color' => '#24252A',
                        'bg_color' => '#F2F2F2',
                        'bg_border_color' => '#F2F2F2',
                    ];
                }
                $oss = Env::get('host.photo');
                $introList = [
                    [
                        'title' => '你最大的用神是',
                        'tag_list' => [
                            [
                                'name' => $HoroscopeReportInfo['content']['yongshen'],
                                'color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['color'],
                                'bg_color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['bg_color'],
                                'bg_border_color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['bg_border_color'],
                            ],
                        ],
                        'title_replace' => '',
                        'title_replace_color' => '',
                        'title_color' => '#24252A',
                    ], [
                        'title' => '你最吉利的方向是',
                        'tag_list' => [
                            [
                                'name' => $HoroscopeReportInfo['content']['fangxiang'],
                                'color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['color'],
                                'bg_color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['bg_color'],
                                'bg_border_color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['bg_border_color'],
                            ],
                        ],
                        'title_replace' => '',
                        'title_replace_color' => '',
                        'title_color' => '#24252A',
                    ], [
                        'title' => '你的幸运颜色是',
                        'tag_list' => [
                            [
                                'name' => $HoroscopeReportInfo['content']['yanse'],
                                'color' => $colorConfig['color_color'][$wuxingAttr]['color'],
                                'bg_color' => $colorConfig['color_color'][$wuxingAttr]['bg_color'],
                                'bg_border_color' => $colorConfig['color_color'][$wuxingAttr]['bg_border_color'],
                            ],
                        ],
                        'title_replace' => '',
                        'title_replace_color' => '',
                        'title_color' => '#24252A',
                    ], [
                        'title' => '如果取名字建议用[REPLACE]属性字',
                        'tag_list' => [],
                        'title_replace' => "“{$wuxingAttr}”",
                        'title_replace_color' => $colorConfig['wuxing_attr_color'][$wuxingAttr]['bg_color'],
                        'title_color' => '#24252A',
                    ], [
                        'title' => '例如：',
                        'tag_list' => $qumingTexts,
                        'title_replace' => '',
                        'title_replace_color' => '',
                        'title_color' => '#9FA1AA',
                    ],
                ];

                $HoroscopeReportInfo['content']['wangshuai']['tag_list'] = $HoroscopeReportModel->tagListUnique($HoroscopeReportInfo['content']['wangshuai']['tag_list']);
                $HoroscopeReportInfo['content']['diaohou']['tag_list'] = $HoroscopeReportModel->tagListUnique($HoroscopeReportInfo['content']['diaohou']['tag_list']);
                $HoroscopeReportInfo['content']['bingyao']['tag_list'] = $HoroscopeReportModel->tagListUnique($HoroscopeReportInfo['content']['bingyao']['tag_list']);
                $HoroscopeReportInfo['content']['geju']['tag_list'] = $HoroscopeReportModel->tagListUnique($HoroscopeReportInfo['content']['geju']['tag_list']);

                $analysis = [
                    'title_img' => $oss . '/test/horoscope/title1_ysfx.png',
                    'list' => [
                        $HoroscopeReportInfo['content']['wangshuai'],
                        $HoroscopeReportInfo['content']['diaohou'],
                        $HoroscopeReportInfo['content']['bingyao'],
                        $HoroscopeReportInfo['content']['geju'],
                    ],
                ];
                $tiangan = [];
                foreach ($HoroscopeReportInfo['content']['yongshenzhenghe']['tiangan'] as $text => $level)
                {
                    $level = $level > 0 ? (string)$level : '';
                    $tiangan[] = [
                        'name' => $text,
                        'level' => $level,
                    ];
                }
                $dizhi = [];
                foreach ($HoroscopeReportInfo['content']['yongshenzhenghe']['dizhi'] as $text => $level)
                {
                    $level = $level > 0 ? (string)$level : '';
                    $dizhi[] = [
                        'name' => $text,
                        'level' => $level,
                    ];
                }
                $integration = [
                    'title_img' => $oss . '/test/horoscope/title1_yszh.png',
                    'des' => '通过以上分析，得出您的各用神及用神等级如下表（等级越高越重要）',
                    'tiangan' => $tiangan,
                    'dizhi' => $dizhi,
                ];

                $horoscopeConfig = (new AppConfig())->configInfo('horoscope');
                $goodList = [];
                if (isset($horoscopeConfig['yongshen_recommend_gids']) && $horoscopeConfig['yongshen_recommend_gids'])
                {
                    $gids = explode(',', $horoscopeConfig['yongshen_recommend_gids']);

                    $gids = array_slice($gids, 0, 3);
                    $mallGoodsModel = new MallGoods();
                    $newGoodsInfo = $mallGoodsModel->batGetInfo($gids, ['id', 'imgs', 'name', 'now_price']);//获取不包含当前商品的六个商品信息
                    foreach ($newGoodsInfo as $goodItem)
                    {
                        $img = $goodItem['imgs'] ? explode(',', $goodItem['imgs'])[0] : '';
                        $goodList[] = [
                            'name' => $goodItem['name'],
                            'des' => '¥' . $goodItem['now_price'],
                            'img' => $img ? $img . '?x-oss-process=style/scale0.2' : '',
                            'target' => 'local',
                            'link' => "mall_store_goods_detail?gid={$goodItem['id']}&need_auth=0",
                        ];
                    }
                }
                $goodThings = $goodList ? [
                    'title_img' => $oss . '/test/horoscope/title1_yshw.png',
                    'des' => '以下是根据你的用神推荐的调整运势的好物',
                    'list' => $goodList,
                ] : null;

                $recodeData = (new Util())->getFortuneDetailRecodeInfo([$HoroscopeReportInfo['recode_info']], $this->user['rid']);
                $unlockRecodeInfo = [
                    'recode_is_change' => 0,
                    'info' => $recodeData,
                    'change_title' => '',
                    'change_desc' => '',
                    'target' => '',
                    'link' => '',
                    'btn_name' => '',
                ];
                if ($HoroscopeReportInfo['recode_is_change'] === true)
                {   // 档案已更新 或者 状态在计算中 展示档案更新提示
                    $unlockRecodeInfo['recode_is_change'] = 1;
                    $unlockRecodeInfo['change_title'] = '检测到当前档案出生时间已发生修改';
                    $unlockRecodeInfo['change_desc'] = '已计算的内容不会随着档案的修改重新计算。';
                    $unlockRecodeInfo['target'] = 'local';
                    $unlockRecodeInfo['link'] = "pay_order?type=28&rid={$rid}&gid=106&need_auth=1";
                    $unlockRecodeInfo['btn_name'] = '再次开通';
                }
                break;
            default:
                // 状态 1【计算中】 或者 3【计算失败】
                return show(config('code.success'), '请求成功', ['status' => 2]);
        }

        $resData = [
            'status' => $status,
            'intro' => $intro,
            'good_year' => $goodYear ?? null,
            'bad_year' => $badYear ?? null,
            'intro_list' => $introList ?? null,
            'analysis' => $analysis ?? null,
            'integration' => $integration ?? null,
            'good_things' => $goodThings ?? null,
            'unlock_recode_info' => $unlockRecodeInfo ?? null,
            'id' => $HoroscopeReportInfo['id'],
        ];

        return show(config('code.success'), '请求成功', $resData);
    }

    /**
     * 用神详解 计算
     */
    public function yongshenCalculate()
    {
        $goodYears = rtrim(input('good_years/s', ''), ',');
        $badYears = rtrim(input('bad_years/s', ''), ',');
        $id = input('id/d', 0);
        $goodYearsArr = $goodYears ? explode(',', $goodYears) : [];
        $badYearsArr = $badYears ? explode(',', $badYears) : [];

        if (!$id || count($goodYearsArr) > 3 || count($badYearsArr) > 3)
        {
            return show(config('code.error'), '请求异常，请稍后再试～');
        }
        if (Util::commentCheck($this->user['id'], ['action' => 'yongshenCalculate'], 10))
        {   // 10 秒内 只能计算一次
            return show(config('code.error'), '请求频繁，请稍后再试～');
        }
        $HoroscopeReportModel = new Zl4HoroscopeReport();
        $yongshenInfo = $HoroscopeReportModel->where(['id' => $id])->field('id,rid,uid,status,type,recode_info')->find();
        if ($yongshenInfo)
        {
            if ((int)$yongshenInfo['uid'] !== $this->user['id'] || (int)$yongshenInfo['type'] !== 2)
            {
                return show(config('code.error'), '服务异常，数据不存在');
            }
            $status = (int)$yongshenInfo['status'];
            switch ($status)
            {
                case 0:
                    $updateData = [];
                    if ($goodYearsArr || $badYearsArr)
                    {   // 未跳过 选择
                        $recodeInfo = json_decode($yongshenInfo['recode_info'], true);
                        $years = [];
                        $nowYear = date('Y');
                        for ($i = 1; $i <= 20; $i++)
                        {
                            $y = $nowYear - $i;
                            if ($y > $recodeInfo['year'])
                            {
                                $years[] = $y;
                            } else
                            {
                                break;
                            }
                        }
                        foreach ($goodYearsArr as $goodYearItem)
                        {
                            if (!in_array((int)$goodYearItem, $years, true))
                            {
                                return show(config('code.error'), '最好的年份选择异常，请重新操作～');
                            }
                        }
                        foreach ($badYearsArr as $badYearItem)
                        {
                            if (!in_array((int)$badYearItem, $years, true))
                            {
                                return show(config('code.error'), '最不好的年份选择异常，请重新操作～');
                            }
                        }
                        $updateData['good_years'] = $goodYears;
                        $updateData['bad_years'] = $badYears;
                    }
                    // 更新计算状态
                    $updateData['status'] = 1;
                    $updateData['start_time'] = time();
                    $HoroscopeReportModel->UpdateData($id, $yongshenInfo['rid'], $updateData);
                    // 发送计算队列
                    Util::queuePush('horoscope_report_calculate', ['id' => $id], 0);
                    return show(config('code.success'), '计算成功');
                    break;
                case 1:
                    return show(config('code.success'), '计算成功');
                    break;
                default:
                    return show(config('code.error'), '服务异常，请稍后再试～');
            }
        } else
        {
            return show(config('code.error'), '服务异常，数据不存在');
        }
    }

    /**
     * 72格局判定 详情
     * @return Json
     * @throws \Exception
     */
    public function Pattern72Decision()
    {
        $rid = input('rid/d', 0);

        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }

        $HoroscopeReportModel = new Zl4HoroscopeReport();

        $HoroscopeReportInfo = $HoroscopeReportModel->getReport($recodeInfo, [1]);

        if (empty($HoroscopeReportInfo))
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }
        $HoroscopeReportInfo = current($HoroscopeReportInfo);

        if ($HoroscopeReportInfo['status'] !== 2)
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }

        $content = $HoroscopeReportInfo['content'] ?? [];
        if (empty($content))
        {   // 重新计算
            Util::queuePush('horoscope_report_calculate', ['id' => $HoroscopeReportInfo['id']], 0);

            return show(config('code.error'), '服务异常，请稍后再试～');
        }

        $oss = Env::get('host.photo');
        $neige = [
            'title_img' => $oss . '/test/horoscope/title2_ngjpdjx.png',
            'des' => '',
            'item' => [],
        ];
        $totalScore = 0;
        $totalScore2 = 0;
        if (isset($content['neige']) && $content['neige'])
        {
            $content['neige']['score1'] = ceil($content['neige']['score1']);
            $content['neige']['score1'] = min($content['neige']['score1'], $content['neige']['score1']);
            $totalScore += $content['neige']['score1'];
            $totalScore2 += $content['neige']['score2'];
            $neige['item'][] = [
                'icon' => $oss . '/test/horoscope/icon1_1.png',
                'title' => $content['neige']['title'],
                'content' => $content['neige']['content'],
                'tag_info' => [
                    'score1' => (string)$content['neige']['score1'],
                    'score2' => "/{$content['neige']['score2']}分",
                    'text_color' => '#EE904B',
                    'bg_color' => '#FFF9F3',
                    'bg_border_color' => '#F9CEA4',
                    'tag_list' => $content['neige']['tag_list'],
                    'title' => '格局分：',
                    'icon' => $oss . '/test/horoscope/icon1_2.png',
                    'content' => '',
                ],
                'type' => 1,
            ];
        } else
        {
            $neige['item'][] = [
                'icon' => '',
                'title' => '',
                'content' => '该档案暂无内格局',
                'tag_info' => null,
                'type' => 2,
            ];
        }
        $waige = [
            'title_img' => $oss . '/test/horoscope/title2_wgjpdjx.png',
            'des' => '外格不是必然存在的，大多数也仅是起到锦上添花的作用，因此赋分较低。请以参考内格为主。',
            'item' => [],
        ];
        if (isset($content['waige']) && $content['waige'])
        {
            foreach ($content['waige'] as $value)
            {
                $value['score1'] = ceil($value['score1']);
                $value['score1'] = min($value['score2'], $value['score1']);
                $totalScore += $value['score1'];
                $totalScore2 += $value['score2'];
                $waige['item'][] = [
                    'icon' => $oss . '/test/horoscope/icon2_1.png',
                    'title' => $value['title'],
                    'content' => $value['content'],
                    'tag_info' => [
                        'score1' => (string)$value['score1'],
                        'score2' => "/{$value['score2']}分",
                        'text_color' => '#9266F2',
                        'bg_color' => '#F9F6FF',
                        'bg_border_color' => '#DCD1F1',
                        'tag_list' => $value['tag_list'],
                        'title' => '格局分：',
                        'icon' => $oss . '/test/horoscope/icon2_2.png',
                        'content' => '',
                    ],
                    'type' => 1,
                ];
            }
        } else
        {
            $waige['item'][] = [
                'icon' => '',
                'title' => '',
                'content' => '该档案暂无外格局',
                'tag_info' => null,
                'type' => 2,
            ];
        }

        $list = [
            $neige,
            $waige,
            [
                'title_img' => $oss . '/test/horoscope/title2_ztgj.png',
                'des' => '',
                'item' => [
                    [
                        'icon' => '',
                        'title' => '',
                        'content' => '',
                        'tag_info' => [
                            'score1' => "{$totalScore}",
                            'score2' => "/{$totalScore2}分",
                            'text_color' => '#E07C25',
                            'bg_color' => '#FFF5F2',
                            'bg_border_color' => '#EECDC3',
                            'tag_list' => $content['zhengti']['tag_list'],
                            'title' => '格局总分：',
                            'icon' => $oss . '/test/horoscope/icon3_2.png',
                            'content' => $content['zhengti']['content'],
                        ],
                        'type' => 1,
                    ],
                ],
            ],
        ];

        $recodeData = (new Util())->getFortuneDetailRecodeInfo([$HoroscopeReportInfo['recode_info']], $this->user['rid']);
        $unlockRecodeInfo = [
            'recode_is_change' => 0,
            'info' => $recodeData,
            'change_title' => '',
            'change_desc' => '',
            'target' => '',
            'link' => '',
            'btn_name' => '',
        ];
        if ($HoroscopeReportInfo['recode_is_change'] === true)
        {   // 档案已更新 或者 状态在计算中 展示档案更新提示
            $unlockRecodeInfo['recode_is_change'] = 1;
            $unlockRecodeInfo['change_title'] = '检测到当前档案出生时间已发生修改';
            $unlockRecodeInfo['change_desc'] = '已计算的内容不会随着档案的修改重新计算。';
            $unlockRecodeInfo['target'] = 'local';
            $unlockRecodeInfo['link'] = "pay_order?type=28&rid={$rid}&gid=107&need_auth=1";
            $unlockRecodeInfo['btn_name'] = '再次开通';
        }

        $resData = [
            'list' => $list,
            'unlock_recode_info' => $unlockRecodeInfo,
        ];

        return show(config('code.success'), '请求成功', $resData);
    }

    /**
     * 八字 吉日吉时 首页
     * @return Json
     * @throws \Exception
     */
    public function goodTimeHome()
    {
        $rid = input('rid/d', 0);
        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }

        $recodeHashKey = Util::getRecodeHashKey($recodeInfo);

        $goodTimeType = (new Zl4GoodTimeType())->getTypes();
        // 获取所有事项类型 的事项标签信息
        $resData = (new Zl4GoodTimeTag())->getTypesAllTids($goodTimeType);

        $HoroscopeGoodTimeModel = new Zl4HoroscopeGoodTime();
        $inCommonUseTab = [
            'name' => '常用',
            'icon' => '/test/horoscope/in_common_use_tab.png',
            'tids' => [25, 3, 18, 22, 4, 21, 26, 13], // 25=>婚礼 3=>出行 18=>搬迁 22=>约会 4=>聚餐 21=>送礼 26=>开业 13=>就医
        ];
        // 获取用户已结果标签信息
        $tagsData = $HoroscopeGoodTimeModel->getUnlockTags($this->user['id']);
        foreach ($inCommonUseTab['tids'] as $tidItem)
        {
            if (!isset($tagsData[$tidItem]))
            {
                $tagsData[$tidItem] = $tidItem;
            }
        }
        $tagsData = array_keys($tagsData);
        $inCommonUseTab['tids'] = array_slice($tagsData, 0, 8);
        array_unshift($resData['tabs'], $inCommonUseTab);
        // 获取用户已解锁 情况
        $unlockData = $HoroscopeGoodTimeModel->getUserUnlockDates($this->user['id']);

        $unlockKey = "{$rid}:0:{$recodeHashKey}:";
        foreach ($resData['tags'] as $k => $tagItem)
        {
            if (isset($unlockData[$unlockKey . $tagItem['id']]))
            {
                $resData['tags'][$k]['unlock_dates'] = $unlockData[$unlockKey . $tagItem['id']];
            } else
            {
                $resData['tags'][$k]['unlock_dates'] = [];
            }
        }

        $resData['current_date'] = date('Y-m-d');

        $isNewInfo = (new Zl4HoroscopeGoodTimeIsNew())->getIsNewStatusCacheData($this->user['id']);
        $resData['new_msg'] = $isNewInfo['is_new'];

        return show(config('code.success'), '请求成功', $resData);
    }

    /**
     * 八字 吉日吉时 免费计算
     * @return Json
     * @throws \Exception
     */
    public function postGoodTimeSimplenessCalculate()
    {
        $rid = input('rid/d', 0);
        $rid2 = input('rid2/d', 0);
        $tid = input('tid/d', 0);
        $startTime = input('start_time/s', '');
        $endTime = input('end_time/s', '');

        if (!$rid || !$tid || !$startTime || !$endTime)
        {
            return show(config('code.error'), '请求异常，请稍后再试～');
        }
        $startTimestamp = strtotime($startTime);
        $endTimestamp = strtotime($endTime);

        if (date('Y-m-d', $startTimestamp) !== $startTime || date('Y-m-d', $endTimestamp) !== $endTime)
        {
            return show(config('code.error'), '时间范围时间格式错误');
        }

        $nowDayTimestamp = strtotime(date('Y-m-d'));

        if ($nowDayTimestamp > $startTimestamp)
        {
            return show(config('code.error'), '起始时间选择异常');
        }

        if ($endTimestamp <= $startTimestamp)
        {
            return show(config('code.error'), '截止时间不能小于起始时间');
        }

        $unlockDayNum = ($endTimestamp - $startTimestamp) / 86400 + 1;
        if ($unlockDayNum < 7)
        {
            return show(config('code.error'), '解锁时间范围不可小于7天');
        }

        if ($unlockDayNum > 365)
        {
            return show(config('code.error'), '解锁时间范围最大365天');
        }

        $recodeInfo = (new RecodeModel())->getInfoById($rid);
        if (!$recodeInfo || $recodeInfo['uid'] != $this->user['id'])
        {
            return show(config('code.error'), '请求异常，档案不存在～');
        }
        $recodeHashKey = Util::getRecodeHashKey($recodeInfo);

        $tagInfo = (new Zl4GoodTimeTag())->getInfoById($tid);
        if (!$tagInfo)
        {
            return show(config('code.error'), '服务异常，事项不存在！');
        }

        $cacheData = [
            'rid1' => $rid,
            'tid' => $tid,
            'recode_info' => [
                'recode1' => $recodeInfo,
                'recode2' => null,
            ],
        ];
        if ($tagInfo['type'] === 2)
        {
            $recodeInfo2 = (new RecodeModel())->getInfoById($rid2);
            if (!$recodeInfo2 || $recodeInfo2['uid'] != $this->user['id'])
            {
                return show(config('code.error'), '请求异常，档案不存在～');
            }
            $cacheData['recode_info']['recode2'] = $recodeInfo2;
            $recodeHashKey2 = Util::getRecodeHashKey($recodeInfo2);
            // 更新 recode hash
            $recodeHashKey = md5($recodeHashKey . $recodeHashKey2);
            $unlockKey = "{$rid}:{$rid2}:{$recodeHashKey}:{$tid}";
            $cacheData['rid2'] = $rid2;
            $cacheData['hash'] = $recodeHashKey;
        } else
        {
            $unlockKey = "{$rid}:0:{$recodeHashKey}:{$tid}";
            $cacheData['rid2'] = 0;
            $cacheData['hash'] = $recodeHashKey;
        }
        // 获取用户已解锁 情况
        $HoroscopeGoodTimeModel = new Zl4HoroscopeGoodTime();
        $unlockData = $HoroscopeGoodTimeModel->getUserUnlockDates($this->user['id'], $unlockKey);
        $unlockData = $unlockData[$unlockKey];
        if ($unlockData)
        {   // 有解锁的天数
            $unlockDayNum = 0;
            $t = $startTimestamp;
            $n = 0;
            $unlockDataItem = [];
            $unlockDays = [];
            $unlockedDays = []; // 已解锁时间范围
            $unlockedDayNum = 0; // 已解锁 天数
            do
            {
                $td = date('Y-m-d', $t);
                if ($n === 0)
                {
                    if (!in_array($td, $unlockData, true))
                    {   // 当前 日期 未解锁
                        $unlockDataItem = [$t];
                        $n = 1;
                        $unlockDayNum++;
                    } else
                    {   // 已解锁
                        if (empty($unlockedDays))
                        {
                            $unlockedDays[0] = $t;
                        } else
                        {
                            $unlockedDays[1] = $t;
                        }
                        $unlockedDayNum++;
                    }
                } else
                {
                    if (in_array($td, $unlockData, true))
                    {   // 如果解锁了
                        $unlockDataItem[] = $t - 86400;
                        $unlockDays[] = $unlockDataItem;
                        $unlockDataItem = [];
                        $n = 0;
                        if (empty($unlockedDays))
                        {
                            $unlockedDays[0] = $t;
                        } else
                        {
                            $unlockedDays[1] = $t;
                        }
                        $unlockedDayNum++;
                    } else
                    {
                        $unlockDayNum++;
                    }
                }
                $t += 86400;
            } while ($t <= $endTimestamp);
            if ($unlockDataItem)
            {
                $unlockDataItem[] = $endTimestamp;
                $unlockDays[] = $unlockDataItem;
            }
            $cacheData['unlock_day_num'] = $unlockDayNum;   // 未解锁天数
            $cacheData['unlocked_day_num'] = $unlockedDayNum;   // 已解锁天数
            $cacheData['unlocked_days'] = $unlockedDays;
        } else
        {
            $unlockDays = [[$startTimestamp, $endTimestamp]];
            $cacheData['unlock_day_num'] = $unlockDayNum;   // 未解锁天数
            $cacheData['unlocked_day_num'] = 0;   // 已解锁天数
            $cacheData['unlocked_days'] = [];
        }
        if ($cacheData['unlock_day_num'] < 7)
        {
            return show(config('code.error'), '未解锁天数不可小于7天');
        }
        $goodInfo = (new Goods())->getInfoById($tagInfo['gid']);

        $cacheData['gid'] = $tagInfo['gid'];
        $cacheData['unlock_days'] = $unlockDays;   // 未解锁天数
        $cacheData['or_prize'] = $goodInfo['now_prize'] * $unlockDayNum;
        switch (true)
        {
            case $unlockDayNum >= 90:
                $discount = isset($tagInfo['extend']['discount']['discount_90']) && $tagInfo['extend']['discount']['discount_90'] && $tagInfo['extend']['discount']['discount_90'] > 0 ? $tagInfo['extend']['discount']['discount_90'] : 1;
                $discount2 = $discount;
                break;
            case $unlockDayNum >= 60:
                $discount = isset($tagInfo['extend']['discount']['discount_60']) && $tagInfo['extend']['discount']['discount_60'] && $tagInfo['extend']['discount']['discount_60'] > 0 ? $tagInfo['extend']['discount']['discount_60'] : 1;
                $discount2 = isset($tagInfo['extend']['discount']['discount_90']) && $tagInfo['extend']['discount']['discount_90'] && $tagInfo['extend']['discount']['discount_90'] > 0 ? $tagInfo['extend']['discount']['discount_90'] : 1;
                $discount2 = min($discount, $discount2);
                break;
            case $unlockDayNum >= 30:
                $discount = isset($tagInfo['extend']['discount']['discount_30']) && $tagInfo['extend']['discount']['discount_30'] && $tagInfo['extend']['discount']['discount_30'] > 0 ? $tagInfo['extend']['discount']['discount_30'] : 1;
                $discount2 = isset($tagInfo['extend']['discount']['discount_60']) && $tagInfo['extend']['discount']['discount_60'] && $tagInfo['extend']['discount']['discount_60'] > 0 ? $tagInfo['extend']['discount']['discount_60'] : 1;
                $discount2 = min($discount, $discount2);
                break;
            default:
                $discount2 = isset($tagInfo['extend']['discount']['discount_30']) && $tagInfo['extend']['discount']['discount_30'] && $tagInfo['extend']['discount']['discount_30'] > 0 ? $tagInfo['extend']['discount']['discount_30'] : 1;
                $discount = 1;
                $discount2 = min($discount, $discount2);
        }
        $cacheData['now_prize'] = $goodInfo['now_prize'] * $unlockDayNum * $discount;

        $data = [
            'uid' => $this->user['id'],
            'hash' => $cacheData['hash'],
            'rid1' => $cacheData['rid1'],
            'rid2' => $cacheData['rid2'],
            'tid' => $cacheData['tid'],
            'status' => 1,
            'start_date' => $startTimestamp,
            'end_date' => $endTimestamp,
            'day_num' => 0,
            'unlock_day_num' => $cacheData['unlock_day_num'],
            'unlock_days' => $cacheData['unlock_days'],
            'content' => '',
            'recode_info' => $cacheData['recode_info'],
            'extend' => [
                'unlocked_day_num' => $cacheData['unlocked_day_num'],   // 已解锁天数
                'unlocked_days' => $cacheData['unlocked_days'],     // 已解锁 时间范围
                'gid' => $cacheData['gid'],
                'or_prize' => $cacheData['or_prize'],
                'now_prize' => $cacheData['now_prize'],
                'discount1' => $discount,  // 当前折扣
                'discount2' => $discount2,  // 下次折扣
            ],
            'create_time' => $this->request->time(),
        ];

        $id = (new Zl4HoroscopeGoodTimeTemp())->SaveData($data);

        if ($id)
        {   // 八字  吉日吉时  计算 入队
            Util::queuePush('horoscope_good_time_report_calculate', ['id' => $id], 0);

            return show(config('code.success'), '请求成功', [
                'id' => $id,
            ]);
        } else
        {
            return show(config('code.error'), '服务异常，请稍后再试～');
        }
    }

    /**
     * 获取 吉日吉时 免费计算结果
     */
    public function getGoodTimeSimplenessCalculateResult()
    {
        $id = input('id/d', 0);

        $GoodTimeSimData = (new Zl4HoroscopeGoodTimeTemp())->getInfoById($id, ['uid', 'tid', 'status', 'start_date', 'end_date', 'day_num', 'unlock_day_num', 'content', 'extend']);

        if ($GoodTimeSimData && $GoodTimeSimData['uid'] === $this->user['id'])
        {
            if ($GoodTimeSimData['status'] === 1)
            {
                // 计算中 防止缓存错误 删除缓存
                CacheManage::getInstance()->setCacheConfig('horoscope.good_time_report_temp', $id)->rmCache();

                return show(config('code.success'), '请求成功', [
                    'status' => 1,
                    'delay_unlock_data' => null,
                    'unlock_data' => null,
                ]);
            }

            $tagInfo = (new Zl4GoodTimeTag())->getInfoById($GoodTimeSimData['tid']);

            if ($GoodTimeSimData['day_num'] > 0)
            {
                $discount1 = ($GoodTimeSimData['extend']['discount1'] ?? 1) * 10;
                $discount2 = ($GoodTimeSimData['extend']['discount2'] ?? 1) * 10;
                $des2Replace1 = '';
                switch (true)
                {
                    case  $GoodTimeSimData['unlock_day_num'] >= 90:
                        if ($discount1 < 10)
                        {
                            $des2Replace1 = "已享{$discount1}折";
                        }
                        break;
                    case  $GoodTimeSimData['unlock_day_num'] >= 60:
                        if ($discount1 < 10 && $discount2 === $discount1)
                        {
                            $des2Replace1 = "已享{$discount1}折";
                        } elseif ($discount1 < 10 && $discount1 > $discount2)
                        {
                            $des2Replace1 = "已享{$discount1}折，解锁满90天可享{$discount2}折";
                        } elseif ($discount1 === 10 && $discount1 > $discount2)
                        {
                            $des2Replace1 = "解锁满90天可享{$discount2}折";
                        }
                        break;
                    case  $GoodTimeSimData['unlock_day_num'] >= 30:
                        if ($discount1 < 10 && $discount2 === $discount1)
                        {
                            $des2Replace1 = "已享{$discount1}折";
                        } elseif ($discount1 < 10 && $discount1 > $discount2)
                        {
                            $des2Replace1 = "已享{$discount1}折，解锁满60天可享{$discount2}折";
                        } elseif ($discount1 === 10 && $discount1 > $discount2)
                        {
                            $des2Replace1 = "解锁满60天可享{$discount2}折";
                        }
                        break;
                    default:
                        if ($discount2 < 10)
                        {
                            $des2Replace1 = "解锁满30天可享{$discount2}折";
                        }
                }

                $des2 = $des2Replace1 ? '[REPLACE1]，解锁后可查看[REPLACE2]，每天都会有具体的吉时推荐' : '解锁后可查看[REPLACE2]，每天都会有具体的吉时推荐';
                $des2Replace2 = '具体的吉日';
            } else
            {
                $des2 = '暂无未解锁吉日，换个时间范围试试～';
                $des2Replace1 = '';
                $des2Replace2 = '';
            }

            if (Util::IsIos() && Util::CheckAppVersion('2.9.7') === '大')
            {
                $nowPrize = floor($GoodTimeSimData['extend']['now_prize'] * 10);
                $orPrize = floor($GoodTimeSimData['extend']['or_prize'] * 10);
                $btnName = "{$nowPrize}准币解锁";
                $btnNameDes = $orPrize > $nowPrize ? "{$orPrize}准币" : '';
            } else
            {
                $btnName = "{$GoodTimeSimData['extend']['now_prize']}元解锁";
                $btnNameDes = $GoodTimeSimData['extend']['or_prize'] > $GoodTimeSimData['extend']['now_prize'] ? "{$GoodTimeSimData['extend']['or_prize']}元" : '';
            }

            $resData = [
                'delay_unlock_data' => [
                    'title' => "适宜{$tagInfo['name']}的日子",
                    'des' => sprintf("%s至%s", date('Y-m-d', $GoodTimeSimData['start_date']), date('Y-m-d', $GoodTimeSimData['end_date'])),
                    'day_num' => $GoodTimeSimData['day_num'],
                    'unlock_day' => $GoodTimeSimData['unlock_day_num'],
                    'btn_name' => $btnName,
                    'btn_name_des' => $btnNameDes,
                    'target' => $GoodTimeSimData['unlock_day_num'] < 7 ? 'toast' : 'local',
                    'link' => $GoodTimeSimData['unlock_day_num'] < 7 ? '未解锁天数不能小于7天，请重新选择时间范围' : "pay_order?type=28&gid={$GoodTimeSimData['extend']['gid']}&history_id={$id}&need_auth=1",
                    'des2' => $des2,
                    'des2_replace1' => $des2Replace1,
                    'des2_replace2' => $des2Replace2,
                ],
                'unlock_data' => null,
                'status' => 2,
            ];

            if ($GoodTimeSimData['extend']['unlocked_day_num'] > 0)
            {
                $GoodTimeSimData['extend']['unlocked_days'][1] = $GoodTimeSimData['extend']['unlocked_days'][1] ?? $GoodTimeSimData['extend']['unlocked_days'][0];
                $dayList = [];
                $monthList = [];
                foreach ($GoodTimeSimData['content']['jishi'] as $jr => $js)
                {
                    $jrTime = strtotime($jr);
                    if ($jrTime >= $GoodTimeSimData['extend']['unlocked_days'][0] && $GoodTimeSimData['extend']['unlocked_days'][1] >= $jrTime)
                    {
                        $m = (int)(date('m', $jrTime));
                        $monthList[$m] = $m;
                        $dayList[] = Zl4HoroscopeGoodTimeTemp::resertGoodTimeData($tagInfo['name'], $jr, $js);
                    }
                }

                $resData['unlock_data'] = [
                    'title' => $resData['delay_unlock_data']['title'],
                    'des' => sprintf("%s至%s", date('Y-m-d', $GoodTimeSimData['extend']['unlocked_days'][0]), date('Y-m-d', $GoodTimeSimData['extend']['unlocked_days'][1])),
                    'day_num' => count($dayList),
                    'unlocked_day' => $GoodTimeSimData['extend']['unlocked_day_num'],
                    'day_list' => $dayList,
                    'month_list' => $monthList ? array_values($monthList) : [],
                ];
            }

            return show(config('code.success'), '请求成功', $resData);
        } else
        {
            return show(config('code.error'), '服务异常，数据不存在～');
        }
    }

    /**
     * 八字 吉日吉时 记录
     * @return Json
     * @throws \Exception
     */
    public function getGoodTimeRecordList()
    {
        $pageData = (new Zl4HoroscopeGoodTime())->getLists($this->user['id']);

        $isNewInfo = (new Zl4HoroscopeGoodTimeIsNew())->getIsNewStatusCacheData($this->user['id']);
        if ($isNewInfo['is_new'] === 1)
        {
            (new Zl4HoroscopeGoodTimeIsNew())->setNewStatus($this->user['id'], 0);
        }

        return show(config('code.success'), '请求成功', $pageData);
    }

    /**
     * 八字 吉日吉时 详情
     */
    public function getGoodTimeDetails()
    {
        $id = input('id/d', 0);

        $GoodTimeData = (new Zl4HoroscopeGoodTime())->getInfoById($id, ['uid', 'tid', 'status', 'start_date', 'unlock_days', 'end_date', 'day_num', 'unlock_day_num', 'content', 'recode_info']);

        if (!$GoodTimeData || $GoodTimeData['uid'] !== $this->user['id'])
        {
            return show(config('code.error'), '服务异常，数据不存在～');
        }

        $tagInfo = (new Zl4GoodTimeTag())->getInfoById($GoodTimeData['tid']);

        $recodeInfo = array_filter($GoodTimeData['recode_info']);

        $recodeData = (new Util())->getFortuneDetailRecodeInfo($recodeInfo, $this->user['rid']);
        $unlockRecodeInfo = [
            'recode_is_change' => 0,
            'info' => $recodeData,
            'change_title' => '',
            'change_desc' => '',
            'target' => '',
            'link' => '',
            'btn_name' => '',
        ];

        $dayList = [];
        $monthList = [];
        foreach ($GoodTimeData['content']['jishi'] as $jr => $js)
        {
            $jrTime = strtotime($jr);

            $n = 0;
            foreach ($GoodTimeData['unlock_days'] as $unlockDaysItem)
            {
                if ($jrTime >= $unlockDaysItem[0] && $jrTime <= $unlockDaysItem[1])
                {
                    $n = 1;
                }
            }
            if ($n === 1)
            {
                $m = (int)(date('m', $jrTime));
                $monthList[$m] = $m;
                $dayList[] = Zl4HoroscopeGoodTimeTemp::resertGoodTimeData($tagInfo['name'], $jr, $js);
            }
        }

        $resData = [
            'title' => "适宜{$tagInfo['name']}的日子",
            'des' => sprintf("%s至%s", date('Y-m-d', $GoodTimeData['start_date']), date('Y-m-d', $GoodTimeData['end_date'])),
            'day_num' => $GoodTimeData['day_num'],
            'day_list' => $dayList,
            'month_list' => $monthList ? array_values($monthList) : [],
            'unlock_recode_info' => $unlockRecodeInfo,
        ];

        return show(config('code.success'), '请求成功', $resData);
    }
}
